using System;
using AvaloniaApplication1.Models;
using AvaloniaApplication1.ViewModels;
using AvaloniaApplication1.ViewModels.CardViewModel;
using Microsoft.Extensions.DependencyInjection;
using SukiUI.Dialogs;

namespace AvaloniaApplication1.Factory;

public class DeviceCardViewModelFactory : ViewModelFactoryBase<DeviceCardModel, DeviceCardViewModel>
{
    private readonly IServiceProvider ServiceProvider;
    private readonly IViewModelFactory<DeviceCardModel, DialogTestViewModel> _dialogTestVmFactory;


    public DeviceCardViewModelFactory(IServiceProvider serviceProvider,
        IViewModelFactory<DeviceCardModel, DialogTestViewModel> dialogTestVmFactory)
        : base(serviceProvider)
    {
        ServiceProvider = serviceProvider;
        _dialogTestVmFactory = dialogTestVmFactory;
    }
    public override DeviceCardViewModel Create(DeviceCardModel model)
    {
        var dialogManager = ServiceProvider.GetRequiredService<ISukiDialogManager>();
        var dialogvm= _dialogTestVmFactory.Create(model);
        return new DeviceCardViewModel(model, dialogManager, dialogvm);
    }
}